package com.ningxun.rms.web.controller.requireapprove;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ningxun.rms.common.annotation.Log;
import com.ningxun.rms.common.core.controller.BaseController;
import com.ningxun.rms.common.core.domain.AjaxResult;
import com.ningxun.rms.common.enums.BusinessType;
import com.ningxun.rms.domain.busrequire.BusRequireApprove;
import com.ningxun.rms.service.baserequire.IBusRequireApproveService;
import com.ningxun.rms.common.utils.poi.ExcelUtil;
import com.ningxun.rms.common.core.page.TableDataInfo;

/**
 * 岗位需求审核Controller
 * 
 * @author rms
 * @date 2025-07-15
 */
@RestController
@RequestMapping("/bus/requireapprove")
public class BusRequireApproveController extends BaseController
{
    @Autowired
    private IBusRequireApproveService busRequireApproveService;

    /**
     * 查询岗位需求审核列表
     */
    @PreAuthorize("@ss.hasPermi('bus:requireapprove:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusRequireApprove busRequireApprove)
    {
        //startPage();
        List<BusRequireApprove> list = busRequireApproveService.selectBusRequireApproveList(busRequireApprove);

        return getDataTable(list);
    }

    /**
     * 导出岗位需求审核列表
     */
    @PreAuthorize("@ss.hasPermi('bus:requireapprove:export')")
    @Log(title = "岗位需求审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusRequireApprove busRequireApprove)
    {
        List<BusRequireApprove> list = busRequireApproveService.selectBusRequireApproveList(busRequireApprove);
        ExcelUtil<BusRequireApprove> util = new ExcelUtil<BusRequireApprove>(BusRequireApprove.class);
        util.exportExcel(response, list, "岗位需求审核数据");
    }

    /**
     * 获取岗位需求审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:requireapprove:query')")
    @GetMapping(value = "/{approveId}")
    public AjaxResult getInfo(@PathVariable("approveId") Long approveId)
    {
        return success(busRequireApproveService.selectBusRequireApproveByApproveId(approveId));
    }

    /**
     * 新增岗位需求审核
     */
    @PreAuthorize("@ss.hasPermi('bus:requireapprove:add')")
    @Log(title = "岗位需求审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusRequireApprove busRequireApprove)
    {
        return toAjax(busRequireApproveService.insertBusRequireApprove(busRequireApprove));
    }

    /**
     * 修改岗位需求审核
     */
    @PreAuthorize("@ss.hasPermi('bus:requireapprove:edit')")
    @Log(title = "岗位需求审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusRequireApprove busRequireApprove)
    {

        return toAjax(busRequireApproveService.updateBusRequireApprove(busRequireApprove));
    }

    /**
     * 删除岗位需求审核
     */
    @PreAuthorize("@ss.hasPermi('bus:requireapprove:remove')")
    @Log(title = "岗位需求审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{approveIds}")
    public AjaxResult remove(@PathVariable Long[] approveIds)
    {
        return toAjax(busRequireApproveService.deleteBusRequireApproveByApproveIds(approveIds));
    }
}
